/**
 * Licensee: Universidad de La Frontera
 * License Type: Academic
 */
package ormsamples;

import org.orm.*;
public class ListTrabajo3pdsData {
	private static final int ROW_COUNT = 100;
	
public void listTestData() throws PersistentException {
		orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
		System.out.println("Listing Administracion...");
		orm.Administracion[] ormAdministracions = lDAOFactory.getAdministracionDAO().listAdministracionByQuery(null, null);
		int length = Math.min(ormAdministracions.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormAdministracions[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Cliente...");
		orm.Cliente[] ormClientes = lDAOFactory.getClienteDAO().listClienteByQuery(null, null);
		length = Math.min(ormClientes.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormClientes[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Administracion by Criteria...");
		orm.AdministracionCriteria lormAdministracionCriteria = new orm.AdministracionCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//lormAdministracionCriteria.id.eq();
		lormAdministracionCriteria.setMaxResults(ROW_COUNT);
		orm.Administracion[] ormAdministracions = lormAdministracionCriteria.listAdministracion();
		int length =ormAdministracions== null ? 0 : Math.min(ormAdministracions.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormAdministracions[i]);
		}
		System.out.println(length + " Administracion record(s) retrieved."); 
		
		System.out.println("Listing Cliente by Criteria...");
		orm.ClienteCriteria lormClienteCriteria = new orm.ClienteCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//lormClienteCriteria.id.eq();
		lormClienteCriteria.setMaxResults(ROW_COUNT);
		orm.Cliente[] ormClientes = lormClienteCriteria.listCliente();
		length =ormClientes== null ? 0 : Math.min(ormClientes.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormClientes[i]);
		}
		System.out.println(length + " Cliente record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListTrabajo3pdsData listTrabajo3pdsData = new ListTrabajo3pdsData();
			try {
				listTrabajo3pdsData.listTestData();
				//listTrabajo3pdsData.listByCriteria();
			}
			finally {
				orm.Trabajo3pdsPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
